﻿using DataTransFrame;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace DataTramsmittingServer
{
    public class CollectClient
    {
        #region 采集端
        public void CollectMsg(object obj)
        {
            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                try
                {
                    IPEndPoint ipe = obj as IPEndPoint;
                    using (TcpClient client = new TcpClient(ipe.Address.ToString(), ipe.Port))
                    {
                        CollectToTranServer cts = new CollectToTranServer();
                        cts.TOPIC = "sdeadgsahdhas";
                        cts.CMD = "CMD";
                        cts.CHECKTIME = DateTime.Now.ToString();
                        cts.RECORDS = "这是一条测试记录！";
                        cts.IDCard = "SME";

                        client.Client.Send(new Common().GetBytesFromProtoObject(cts));
                    }
                }
                catch (Exception ex)
                {
                    System.Threading.Thread.Sleep(10000);
                }
            }
        }
        #endregion
    }
}
